package com.example.myanimator

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.example.myanimator.avoidxfermode.FerModeActivity
import com.example.myanimator.circleanimator.CircleActivity
import com.example.myanimator.drawpictrue.DrawTextActivity
import com.example.myanimator.five.FiveActivity
import com.example.myanimator.mcanvas.CanvasLearningActivity
import com.example.myanimator.one.MainActivity
import com.example.myanimator.scroll.ScrollActivity
import com.example.myanimator.shadowLayer.DrawShadowActivity
import com.example.myanimator.six.SixActivity
import com.example.myanimator.svg.SevenActivity

class StartActivity : AppCompatActivity(), View.OnClickListener {
    private lateinit var bt1: Button
    private lateinit var bt2: Button
    private lateinit var bt3: Button
    private lateinit var bt4: Button
    private lateinit var bt5: Button
    private lateinit var bt6: Button
    private lateinit var bt7: Button
    private lateinit var bt8: Button
    private lateinit var bt9: Button
    //两种方法
    private lateinit var bt10: Button
    private lateinit var bt12: Button
    private lateinit var bt13: Button

    private var bt11: Button? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.start_activity_main)
        bt1 = findViewById(R.id.bt_1)
        bt2 = findViewById(R.id.bt_2)
        bt3 = findViewById(R.id.bt_3)
        bt4 = findViewById(R.id.bt_4)
        bt5 = findViewById(R.id.bt_5)
        bt6 = findViewById(R.id.bt_6)
        bt7 = findViewById(R.id.bt_7)
        bt8 = findViewById(R.id.bt_8)
        bt9 = findViewById(R.id.bt_9)
        bt10 = findViewById(R.id.bt_10)
        bt11 = findViewById(R.id.bt_11)
        bt12 = findViewById(R.id.bt_12)
        bt13 = findViewById(R.id.bt_13)
        bt1.setOnClickListener(this)
        bt2.setOnClickListener(this)
        bt3.setOnClickListener(this)
        bt4.setOnClickListener(this)
        bt5.setOnClickListener(this)
        bt6.setOnClickListener(this)
        bt7.setOnClickListener(this)
        bt8.setOnClickListener(this)
        bt9.setOnClickListener(this)
        bt10.setOnClickListener(this)
        bt12.setOnClickListener(this)
        bt13.setOnClickListener(this)

        bt11?.setOnClickListener(this)
        //点击事件
        bt11?.setOnClickListener {
            startActvvity(CanvasLearningActivity::class.java)
        }
    }

    override fun onClick(v: View) {
        when (v.id) {
            R.id.bt_1 -> {
                startActvvity(MainActivity::class.java)
            }
            R.id.bt_2 -> {
                startActvvity(SecondActivity::class.java)
            }
            R.id.bt_3 -> {
                startActvvity(ThreeActivity::class.java)
            }
            R.id.bt_4 -> {
                startActvvity(FourActivity::class.java)
            }
            R.id.bt_5 -> {
                startActvvity(FiveActivity::class.java)
            }
            R.id.bt_6 -> {
                startActvvity(SixActivity::class.java)
            }
            R.id.bt_7 -> {
                startActvvity(SevenActivity::class.java)
            }
            R.id.bt_8 -> {
                startActvvity(DrawTextActivity::class.java)
            }
            R.id.bt_9 -> {
                startActvvity(DrawShadowActivity::class.java)
            }
            R.id.bt_10 -> {
                startActvvity(FerModeActivity::class.java)
            }
            R.id.bt_11 -> {
//                startActvvity(CanvasLearningActivity::class.java)
            }

            R.id.bt_12 -> {
                startActvvity(ScrollActivity::class.java)
            }
            R.id.bt_13 -> {
                startActvvity(CircleActivity::class.java)
            }
        }
    }

    private fun startActvvity(mainActivityClass: Class<*>) {
        startActivity(Intent(this@StartActivity, mainActivityClass))
    }
}